/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JF_VerBeneficiarios.java
 *
 * Created on 14-mar-2010, 16:45:34
 */

package cliente.presentacion.administrador.beneficiarios;


import cliente.negocio.Controlador_Gestion_Beneficiario;
import java.awt.Toolkit;
import java.util.Calendar;
import java.util.Locale;
import server.dominio.Beneficiario;

/**
 *
 * @author tpaxle
 */
public class JF_VerBeneficiarios extends javax.swing.JFrame implements iJF_VerBeneficiario{

    private Beneficiario beneficairiomostrado;
    private Controlador_Gestion_Beneficiario controlador;
    private int seleccionindex=-1;
    /** Creates new form JF_VerBeneficiarios */
    public JF_VerBeneficiarios(Controlador_Gestion_Beneficiario C_admin) {
        controlador= C_admin;
        initComponents();
        this.setLocation((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth()/4,(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()/6);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        jLabel16 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel19 = new javax.swing.JLabel();
        jTextField_NIF = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField_NSS = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField_med_Nif = new javax.swing.JTextField();
        jTextField_medi_Nombre = new javax.swing.JTextField();
        jTextField_medi_apellidos = new javax.swing.JTextField();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jLabel17 = new javax.swing.JLabel();
        jTextField_ano = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jTextField_email = new javax.swing.JTextField();
        jTextField_dia = new javax.swing.JTextField();
        jTextField_mes = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jTextField_Nombre = new javax.swing.JTextField();
        jTextField_Apellido = new javax.swing.JTextField();
        jTextField_domicilio = new javax.swing.JTextField();
        jTextField_telefonofijo = new javax.swing.JTextField();
        jTextField_telmovil = new javax.swing.JTextField();
        jButton_ok = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/1268112229_list-add-user.png"))); // NOI18N

        jLayeredPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Datos de usuario"));

        jLabel16.setText("Medico:");
        jLabel16.setBounds(10, 100, 55, 20);
        jLayeredPane2.add(jLabel16, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Medico1", "Medico2", "Medico3", " " }));
        jComboBox4.setEnabled(false);
        jComboBox4.setBounds(70, 100, 180, 26);
        jLayeredPane2.add(jComboBox4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel19.setText("NIF:");
        jLabel19.setBounds(10, 70, 40, 20);
        jLayeredPane2.add(jLabel19, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_NIF.setBounds(70, 70, 180, 20);
        jLayeredPane2.add(jTextField_NIF, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setText("NSS");
        jLabel2.setBounds(10, 30, 40, 20);
        jLayeredPane2.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_NSS.setBounds(70, 30, 180, 26);
        jLayeredPane2.add(jTextField_NSS, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Medico Cabecera"));

        jLabel3.setText("Nif");

        jLabel4.setText("Especialidad");

        jLabel5.setText("Nombre");

        jLabel6.setText("Apellidos");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Cabecera", "Pediatría", "Urología", "Cirugía", "Neurología", "Ginecología", "Digestivo", "Oftalmología" }));
        jComboBox1.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(67, 67, 67)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField_med_Nif, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                    .addComponent(jComboBox1, 0, 108, Short.MAX_VALUE))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTextField_medi_Nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                    .addComponent(jTextField_medi_apellidos, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField_medi_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField_med_Nif, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField_medi_apellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel4))
                .addGap(28, 28, 28))
        );

        jLayeredPane3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Datos personales"));

        jLabel17.setText("Fecha de nacimiento:");
        jLabel17.setBounds(20, 200, 130, 20);
        jLayeredPane3.add(jLabel17, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_ano.setBounds(260, 200, 40, 20);
        jLayeredPane3.add(jTextField_ano, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel18.setText("Nombre:");
        jLabel18.setBounds(20, 40, 70, 20);
        jLayeredPane3.add(jLabel18, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel20.setText("Apellidos:");
        jLabel20.setBounds(20, 70, 80, 20);
        jLayeredPane3.add(jLabel20, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel22.setText("Domicilio:");
        jLabel22.setBounds(20, 100, 70, 20);
        jLayeredPane3.add(jLabel22, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel23.setText("Telf. Fijo:");
        jLabel23.setBounds(20, 130, 70, 20);
        jLayeredPane3.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel24.setText("Telf. Movil:");
        jLabel24.setBounds(230, 130, 80, 20);
        jLayeredPane3.add(jLabel24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel25.setText("/");
        jLabel25.setBounds(250, 200, 10, 20);
        jLayeredPane3.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_email.setBounds(100, 160, 330, 20);
        jLayeredPane3.add(jTextField_email, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_dia.setBounds(160, 200, 40, 20);
        jLayeredPane3.add(jTextField_dia, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_mes.setBounds(210, 200, 40, 20);
        jLayeredPane3.add(jTextField_mes, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel26.setText("Email:");
        jLabel26.setBounds(20, 160, 70, 20);
        jLayeredPane3.add(jLabel26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel27.setText("/");
        jLabel27.setBounds(200, 200, 10, 20);
        jLayeredPane3.add(jLabel27, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_Nombre.setBounds(100, 40, 140, 20);
        jLayeredPane3.add(jTextField_Nombre, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_Apellido.setBounds(100, 70, 330, 20);
        jLayeredPane3.add(jTextField_Apellido, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_domicilio.setBounds(100, 100, 330, 20);
        jLayeredPane3.add(jTextField_domicilio, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_telefonofijo.setBounds(100, 130, 110, 20);
        jLayeredPane3.add(jTextField_telefonofijo, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_telmovil.setBounds(310, 130, 120, 20);
        jLayeredPane3.add(jTextField_telmovil, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton_ok.setText("OK");
        jButton_ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_okActionPerformed(evt);
            }
        });

        jButton1.setText("Modificar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(243, 243, 243)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_ok, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addComponent(jLabel1)
                                .addGap(28, 28, 28)
                                .addComponent(jLayeredPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLayeredPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)))
                        .addGap(286, 286, 286)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLayeredPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLayeredPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_ok, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 457, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_okActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_jButton_okActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        controlador.modificarbeneficiario(this.seleccionindex);
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton_ok;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField_Apellido;
    private javax.swing.JTextField jTextField_NIF;
    private javax.swing.JTextField jTextField_NSS;
    private javax.swing.JTextField jTextField_Nombre;
    private javax.swing.JTextField jTextField_ano;
    private javax.swing.JTextField jTextField_dia;
    private javax.swing.JTextField jTextField_domicilio;
    private javax.swing.JTextField jTextField_email;
    private javax.swing.JTextField jTextField_med_Nif;
    private javax.swing.JTextField jTextField_medi_Nombre;
    private javax.swing.JTextField jTextField_medi_apellidos;
    private javax.swing.JTextField jTextField_mes;
    private javax.swing.JTextField jTextField_telefonofijo;
    private javax.swing.JTextField jTextField_telmovil;
    // End of variables declaration//GEN-END:variables

    public void mostrar(Beneficiario beneficiario, int index) {
        seleccionindex= index;
        if (beneficiario != null) {
            beneficairiomostrado= beneficiario;
            
            jTextField_Nombre.setText(beneficiario.getNombre());
            jTextField_NIF.setText(beneficiario.getNif());
            jTextField_Apellido.setText(beneficiario.getApellidos());
            jTextField_domicilio.setText(beneficiario.getDomicilio());
            jTextField_email.setText(beneficiario.getEmail());
            jTextField_telefonofijo.setText("" + beneficiario.getTelefFijo());
            jTextField_telmovil.setText("" + beneficiario.getTelefMovil());


                        //Modificar con calendarios
            Calendar fecha = Calendar.getInstance();
            fecha.setTime(beneficiario.getFechaNacimiento());


            jTextField_ano.setText(""+fecha.get(Calendar.YEAR));
            jTextField_mes.setText(""+fecha.get(Calendar.MONTH));
            jTextField_dia.setText(""+fecha.get(Calendar.DAY_OF_MONTH));


            jTextField_NSS.setText(beneficiario.getNss());
            jTextField_med_Nif.setText(beneficiario.getMedico().getUsuario().getNif());
            jTextField_medi_Nombre.setText(beneficiario.getMedico().getUsuario().getNombre());
            jTextField_medi_apellidos.setText(beneficiario.getMedico().getUsuario().getApellidos());
            jComboBox1.setSelectedIndex(beneficiario.getMedico().getIdTipoMedico()-1);


            this.setVisible(true);

        } else {
            this.setVisible(false);
           // controlador.log("Error, el usuario n0 ha sido pasado");
        }

    }

    public void setSeleccionindex(int seleccionindex) {
        this.seleccionindex = seleccionindex;
    }

}
